package com.gmadmin.configuration;

import com.gmadmin.utils.RedisUtils;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhangliang
 * @version 1.0
 * @date 2022/8/2 15:56
 * 项目初始化
 */
@Configuration
public class InitConfig  implements ApplicationRunner {

    private final RedisUtils redisUtils;

    public InitConfig(RedisUtils redisUtils) {
        this.redisUtils = redisUtils;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //此处仅是举例
//        User user = userMapper.selectById("1");
//        redisUtil.set(String.valueOf(user.getId()),user);
//        User user1 = (User) redisUtil.get(String.valueOf(user.getId()));
//        System.out.println("项目初始化成功，读取结果为：" + user1.getId() + "," + user1.getName());
    }
}
